package com.ljh.controller;

import com.ljh.mapper.AdminMapper;
import com.ljh.mapper.UserMapper;
import com.ljh.pojo.Account;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/account")
public class AccountController {
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private AdminMapper adminMapper;
    @GetMapping("/login/{username}/{password}/{type}")
    public Account login(@PathVariable("username") String username,
                        @PathVariable("password") String password,
                        @PathVariable("type") String type){
        Account account=null;
        switch (type){
            case "user":
                account=userMapper.login(username,password);
                break;
            case "admin":
                account=adminMapper.login(username,password);
                break;

        }
        return account;

    }
    @GetMapping("/index")
    public String index(){
        return "运行成功";
    }
}
